{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "73bd968b-d970-4a05-94ef-4e7abf990827",
   "metadata": {},
   "source": [
    "Chapter 01\n",
    "\n",
    "# 加法\n",
    "Book_3《数学要素》 | 鸢尾花书：从加减乘除到机器学习 (第二版)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eff70c40-3e99-47f4-a51c-6a8b69b62957",
   "metadata": {},
   "source": [
    "该代码定义了两个数字$2$和$3$，然后计算并显示它们的和。\n",
    "\n",
    "### 代码细节\n",
    "\n",
    "1. **定义数字**：代码将两个数分别赋值给变量`num1`和`num2`，其中$ \\text{num1} = 2 $，$ \\text{num2} = 3 $。\n",
    "\n",
    "2. **求和计算**：代码计算两个数的和，并将结果存储在`sum_2_nums`变量中。具体的计算过程如下：\n",
    "\n",
    "   $$\n",
    "   \\text{sum\\_2\\_nums} = \\text{num1} + \\text{num2} = 2 + 3 = 5\n",
    "   $$\n",
    "\n",
    "3. **结果显示**：代码通过格式化字符串输出计算结果，将变量`num1`、`num2`及其和`sum_2_nums`的值插入到输出字符串中，最终显示为“`The sum of 2 and 3 is 5`”。\n",
    "\n",
    "### 总结\n",
    "\n",
    "该代码通过简单的加法运算展示了如何使用Python的格式化输出功能来显示计算结果，强调了数值运算与输出的结合。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0449cc37-eb6a-4b4b-b681-1de28396a1e5",
   "metadata": {},
   "source": [
    "## 定义两个数字并计算其和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "90667c8e-a5ef-4a7d-b41d-2bde55ed2cf7",
   "metadata": {},
   "outputs": [],
   "source": [
    "num1 = 2  # 定义第一个数字\n",
    "num2 = 3  # 定义第二个数字"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba5fc825-980d-47b3-9e02-957969b7af9b",
   "metadata": {},
   "source": [
    "## 计算两个数字的和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "590df95d-7126-40da-8c45-2a4e4639bdbe",
   "metadata": {},
   "outputs": [],
   "source": [
    "sum_2_nums = num1 + num2  # 计算num1和num2的和"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f23d32df-b7c1-4732-b80d-1a0d5c0a61ff",
   "metadata": {},
   "source": [
    "## 显示计算结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bb7061b2-8268-4222-876c-7a7a867a6a84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The sum of 2 and 3 is 5\n"
     ]
    }
   ],
   "source": [
    "print('The sum of {0} and {1} is {2}'.format(num1, num2, sum_2_nums))  # 输出两个数字的和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85a80909-2aac-49ed-bb7a-f8cc6b80ee7d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecd322f4-f919-4be2-adc3-69d28ef25e69",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
